<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			const obj = {
				"I": 1,
				"V": 5,
				"X": 10,
				"L": 50,
				"C": 100,
				"D": 500,
				"M": 1000
			}

			var romanToInt = function(s) {
				let number = 0;
				for (let i = 0; i < s.length; i++) {
					if (obj[s[i]] < obj[s[i + 1]]) {
						number -= obj[s[i]]
					} else {
						number += obj[s[i]]
					}
				}
				return number
			};
			console.log(romanToInt("MCMXCIV"));
			// console.log(romanToInt("DCXXI"));
		</script>
	</body>
</html>
